import { IEnemy, IState } from "../../../Interface/State";
import BTTree from "../../Base/BTTree";
import ActionImpact from "../ActionBoss1/ActionImpact";
import ActionRandomRun from "../ActionBoss1/ActionRandomRun";
import ActionReduceCD from "../ActionBoss1/ActionReduceCD";
import ActionRun from "../ActionBoss1/ActionRun";
import ActionShoot from "../ActionBoss1/ActionShoot";
import CompositeSelector from "../Composite/CompositeSelector";
import CompositeSequence from "../Composite/CompositeSequence";
import ConditionalNoDead from "../Condition/ConditionalNoDead";
import ConditionalPercentageHP from "../Condition/ConditionalPercentageHP";

export default class Boss1Tree extends BTTree {
    constructor(
        public enemy: IEnemy,
        public state: IState,
    ) {
        super()
        this.init();
    }

    init() {
        this.root = new CompositeSequence([
            new ConditionalNoDead(this),
            new ActionReduceCD(this),

            new CompositeSelector([
                new CompositeSequence([
                    new ConditionalPercentageHP(this, 1, 0.6),
                    new ActionRandomRun(this),
                    new ActionShoot(this),
                ]),
                new CompositeSequence([
                    new ConditionalPercentageHP(this, 0.6, 0.2),
                    new ActionRun(this),
                    new ActionImpact(this),
                ]),
                new CompositeSequence([
                    new ConditionalPercentageHP(this, 0.2),
                    new ActionRun(this),
                    new CompositeSequence([
                        new ActionShoot(this),
                        new ActionImpact(this),
                    ])
                ]),
            ])
        ])
    }
}
